<script setup lang="ts">
import { reactive, ref, watch } from 'vue';

  var user = reactive({id:1,name:'zhangsan',age:19})
  watch(user,(newVal,oldVal)=>{
    console.log(oldVal)
    console.log(newVal)
  })
  const changeUser = () => {
    Object.assign(user,{id:2,name:'张三',age:29})
  }
  const changeName = () => {
    user.name = "李四"
  }
</script>
<template>
  {{ user }}
  <br>
  <button @click="changeUser">user</button>
  <button @click="changeName">name</button>
</template>
<style scoped></style>